package bll

import (
	"jgt-oper/src/model"
	"jgt-oper/src/schema"
)

// ContactsBook 通讯录逻辑层
type ContactsBook struct {
	ContactsBookModel model.IContactsBook `inject:"IContactsBook"`
	AuthUserModel     model.IAuthUser     `inject:"IAuthUser"`
}

// GetTotal 查询企业员工总数
func (a *ContactsBook) GetTotal(enterpriseID string) (int, error) {
	return a.ContactsBookModel.GetTotal(enterpriseID)
}

// GetAllColleagues 查询所有的同事
func (a *ContactsBook) GetAllColleagues(enterpriseID string, colleaguesName string) ([]*schema.QueryResultColleagues, error) {
	return a.ContactsBookModel.GetAllColleagues(enterpriseID, colleaguesName)
}

// GetAllFrequentlyUsed 查询所有的常用联系人
func (a *ContactsBook) GetAllFrequentlyUsed(userID string, pageIndex, pageSize uint) ([]*schema.User, error) {
	return a.ContactsBookModel.GetAllFrequentlyUsed(userID, pageIndex, pageSize)
}

// AddFrequentlyUsed 添加常用联系人
func (a *ContactsBook) AddFrequentlyUsed(userID string, frequentlyUsedID string) error {
	err := a.ContactsBookModel.AddFrequentlyUsed(userID, frequentlyUsedID)
	if err != nil {
		return err
	}
	return nil
}

// CancelFrequentlyUsed 取消常用联系人
func (a *ContactsBook) CancelFrequentlyUsed(userID string, frequentlyUsedID string) error {
	err := a.ContactsBookModel.CancelFrequentlyUsed(userID, frequentlyUsedID)
	if err != nil {
		return err
	}
	return nil
}

// GetAuthUser 查询指定用的认证信息
func (a *ContactsBook) GetAuthUser(userID string) (*schema.AuthUser, error) {
	return a.AuthUserModel.Get(userID)
}

// GetColleaguesDetail 查询同事信息详情
func (a *ContactsBook) GetColleaguesDetail(params []string) ([]*schema.UserItemDetail, error) {
	return a.ContactsBookModel.GetColleaguesDetail(params)
}

// GetMyFrequentlyUsed 查询用户-常用联系人对应关系
func (a *ContactsBook) GetMyFrequentlyUsed(userID string) (*schema.ContactsBook, error) {
	return a.ContactsBookModel.GetMyFrequentlyUsed(userID)
}
